/*
 * @Author: Clark
 * @Email: haixuanwoTxh@gmail.com
 * @Date: 2023-01-04 17:14:33
 * @LastEditors: Clark
 * @LastEditTime: 2023-01-04 17:16:49
 * @Description: file content
 */

#include "apue.h"

int main()
{
    char name[L_tmpnam] = {0};
    char line[MAXLINE] = {0};
    FILE *fp = NULL;

    printf("%s\n", tmpnam(NULL));

    tmpnam(name);
    printf("%s\n", name);

    fp = tmpfile();
    if (NULL == fp)
    {
        err_sys("tmpfile error");
    }

    fputs("one line of output\n", fp);
    rewind(fp);

    if (NULL == fgets(line, sizeof(line), fp))
    {
        err_sys("fgets error");
    }
    fputs(line, stdout);

    exit(0);
}
